package com.crr;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class DirectConsumer {
    @RabbitListener(queues = "normal-queue")
    public void handler(Message message, Channel channel){
        System.out.println("订单消费者："+new String(message.getBody()));
        //手动确认或者拒绝
        try {
            channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
